home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 3 / Macwelt DVD 3.cdr / System / Utilities / PhoneManager 1.0.6 / Java for 6310i / First_Aid_Guide.jar / Library_Class.class (.txt) < prev   
Encoding:
Java Class File  |  2002-04-15  |  3.0 KB  |  114 lines

  1. import java.io.ByteArrayOutputStream;
  2. import java.io.DataOutputStream;
  3. import javax.microedition.rms.RecordStore;
  4.  
  5. public class Library_Class {
  6.    private String[] LibStringArray = new String[10];
  7.    RecordStore theLibStore;
  8.    String storeLibName;
  9.    String StringName;
  10.    int recordSize;
  11.    boolean StoreExists = false;
  12.    RecordStore FA_rs = null;
  13.    String FIRST_AID_REC_STORE = "First_Aid_Store";
  14.    String convertString1;
  15.    String convertString2;
  16.    String test;
  17.  
  18.    public boolean testRecStore(RecordStore var1, String var2) {
  19.       this.storeLibName = var2;
  20.       this.theLibStore = var1;
  21.  
  22.       try {
  23.          this.theLibStore = RecordStore.openRecordStore(this.storeLibName, false);
  24.          this.StoreExists = true;
  25.       } catch (Exception var4) {
  26.          this.StoreExists = false;
  27.       }
  28.  
  29.       return this.StoreExists;
  30.    }
  31.  
  32.    public void openRecStore(RecordStore var1, String var2) {
  33.       this.storeLibName = var2;
  34.       this.theLibStore = var1;
  35.  
  36.       try {
  37.          this.theLibStore = RecordStore.openRecordStore(this.storeLibName, true);
  38.       } catch (Exception var4) {
  39.          System.out.println("Error : problem with creating store");
  40.       }
  41.  
  42.    }
  43.  
  44.    public void writeData(String[] var1) {
  45.       try {
  46.          ByteArrayOutputStream var2 = new ByteArrayOutputStream();
  47.          DataOutputStream var3 = new DataOutputStream(var2);
  48.          boolean var5 = true;
  49.  
  50.          for(int var6 = 0; var6 < var1.length; ++var6) {
  51.             var3.writeUTF(var1[var6]);
  52.             var3.flush();
  53.             byte[] var4 = var2.toByteArray();
  54.             this.theLibStore.addRecord(var4, 0, var4.length);
  55.             var2.reset();
  56.          }
  57.  
  58.          var2.close();
  59.          var3.close();
  60.       } catch (Exception var7) {
  61.          System.out.println(" there is an error in write streams1:  " + var7);
  62.       }
  63.  
  64.    }
  65.  
  66.    public void closeRecStore() {
  67.       try {
  68.          this.theLibStore.closeRecordStore();
  69.       } catch (Exception var2) {
  70.          System.out.println(" there is an error closing  the RMS:  " + var2);
  71.       }
  72.  
  73.    }
  74.  
  75.    public void deleteRecStore() {
  76.       if (RecordStore.listRecordStores() != null) {
  77.          try {
  78.             RecordStore.deleteRecordStore(this.storeLibName);
  79.             System.out.println("deleting one ");
  80.          } catch (Exception var2) {
  81.             System.out.println(" there is an error in deleting the store:  " + var2);
  82.          }
  83.       }
  84.  
  85.    }
  86.  
  87.    public String[] readDataNewA(int var1, int var2) {
  88.       int var3 = var1;
  89.       int var4 = var2;
  90.  
  91.       try {
  92.          byte[] var5 = new byte[50];
  93.          int var6 = -1;
  94.  
  95.          for(int var7 = var3; var7 <= var4; ++var7) {
  96.             var5 = new byte[this.theLibStore.getRecordSize(var7)];
  97.             this.theLibStore.getRecord(var7, var5, 0);
  98.             this.convertString1 = new String(var5);
  99.             this.convertString1 = this.convertString1.trim();
  100.             if (this.convertString1.length() > 32) {
  101.                this.convertString1 = this.convertString1.substring(1);
  102.             }
  103.  
  104.             ++var6;
  105.             this.LibStringArray[var6] = this.convertString1.trim();
  106.          }
  107.       } catch (Exception var8) {
  108.          System.out.println(" there is an error in read streams:  " + var8);
  109.       }
  110.  
  111.       return this.LibStringArray;
  112.    }
  113. }
  114.